let express = require('express');
let router = express.Router();
let sql = require("../sql/index");
let uuid = require("node-uuid");
let Banner = require("../sql/collection/Banner");

/* GET activity listing. */
router.get('/', function (req, res, next) {
  res.render('banner', {
    activeIndex: "1",
    role: req.session.role,
    adminname: req.session.adminname
  });
});
router.post('/add', (req, res, next) => {
  const { info, href, imgbase } = req.body;
  sql.insert(Banner, {
    bannerid: "banner_" + uuid.v1(),
    info,
    href,
    imgbase
  }).then((data) => {
    res.send(data);
  })
});
module.exports = router;
